package cn.iocoder.yudao.module.wengfu.dal.mysql.result;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.wengfu.dal.dataobject.result.LaboratoryResultInfoDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.wengfu.controller.admin.result.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 化验结果 Mapper
 *
 * @author yzs
 */
@Mapper
public interface LaboratoryResultInfoMapper extends BaseMapperX<LaboratoryResultInfoDO> {

    default PageResult<LaboratoryResultInfoDO> selectPage(LaboratoryResultInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<LaboratoryResultInfoDO>()
                .eqIfPresent(LaboratoryResultInfoDO::getTestId, reqVO.getTestId())
                .betweenIfPresent(LaboratoryResultInfoDO::getTestDate, reqVO.getTestDate())
                .eqIfPresent(LaboratoryResultInfoDO::getConfirmStatus, reqVO.getConfirmStatus())
                .orderByDesc(LaboratoryResultInfoDO::getId));
    }

    /**
     * 根据 testId 查询所有匹配的化验记录
     */
    @Select("SELECT * FROM laboratory_result WHERE test_id = #{testId}")
    LaboratoryResultInfoDO selectByTestId(@Param("testId") String testId);

}
